package com.mol.market.common.util;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.mol.market.R;
import com.mol.market.ui.HomeActivity;

public class MenuUtil {
    // Menu dialog
    public static final int DIALOG_RESPONSE = 200;

    public static void onMenuSelectedResponse(Context context) {
        final Activity act = (Activity) context;
        if (!act.isFinishing()) {
            // 判断当前网络是否可用
            if (Utils.isNetworkAvailable(context)) {
                act.showDialog(MenuUtil.DIALOG_RESPONSE);
            } else {
                Utils.makeEventToast(context, context.getString(R.string.warning_netword_error),
                        false);
            }
        }
    }

    public static void onMenuSelectedHome(Context context) {
        final Activity act = (Activity) context;
        Intent intent = new Intent(act, HomeActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        act.startActivity(intent);
    }
}
